
package com.thor.palmmall.rest.hdmall.sales.converter;

import org.springframework.core.convert.converter.Converter;

import com.thor.commons.util.ConverterUtil;
import com.thor.palmmall.hdmall.sales.HDMSalesInput;
import com.thor.palmmall.rest.hdmall.sales.MSalesInput;
/**
 * @author:liyang
 * @time:2017年7月25日 下午4:14:30
 * @since:1.0
 */
public class MSalesInputConverter implements Converter<HDMSalesInput, MSalesInput> {

  public static MSalesInputConverter getInstance() {
    if (instance == null)
      instance = new MSalesInputConverter();
    return instance;
  }

  private static MSalesInputConverter instance;

  private MSalesInputConverter() {
  }

  @Override
  public MSalesInput convert(HDMSalesInput source) {
    if (source == null) {
      return null;
    }
    MSalesInput target = new MSalesInput();

    target.setStore(source.getStore());
    target.setTenant(source.getTenant());
    target.setContract(source.getContract());
    target.setOper(source.getOper());
    target.setReceiver(source.getReceiver());
    target.setBalance(source.isBalance());
    target.setSaleDate(source.getSaleDate());
    target.setSaleCount(source.getSaleCount());
    target.setPayments(
        ConverterUtil.convert(source.getPayments(), MSalesInputLineConverter.getInstance()));
    target.setMediaFiles(source.getMediaFiles());
    target.setBillNumber(source.getBillNumber());
    target.setState(source.getState());
    return target;
  }
}
